package com._51cto.healthy.service;

import com._51cto.healthy.base.BaseMapper;
import com._51cto.healthy.content.P;
import com._51cto.healthy.mapper.DiseaseMapper;
import com._51cto.healthy.mapper.HealthyMapper;
import com._51cto.healthy.pojo.Healthy;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class HealthyServiceImpl implements HealthyService{
      @Autowired
      private HealthyMapper healthyMapper;

    @Override
    public BaseMapper<Healthy> getDao() {
        return healthyMapper;
    }
    @Override
    public P<Healthy> findAll(String query, Integer pageSize, Integer pageNum) {
        PageHelper.startPage(pageNum,pageSize);
        List<Healthy> all = healthyMapper.findAll(query);
        PageInfo<Healthy> pageInfo = new PageInfo<>(all);

        return new P<Healthy>().setPages(pageInfo.getPages())
                .setTotal(pageInfo.getTotal())
                .setRows(pageInfo.getList())
                .setPageSize(pageInfo.getPageSize())
                .setPageNum(pageInfo.getPageNum());
    }

    @Override
    public void deleteByPK(Integer pk) {
        HealthyService.super.deleteByPK(pk);
    }

    @Override
    public void insert(Healthy entity) {
        HealthyService.super.insert(entity);
    }

    @Override
    public void update(Healthy entity) {
        HealthyService.super.update(entity);
    }
}
